// pages/component_addBoDan/addBoDan.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {

    title:{
      type:String,
      value:'标题'
    },
    inputName:{
      type:String,
      value:'输入框解释文字'
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

    display:true,
    dbDate:[]
  },

  /**
   * 组件的方法列表
   */
  methods: {

    add:function(){

      var self =  this

      var timestamp3 = new Date().getTime() 

      var id = timestamp3 + 'bd'

      if(this.data.inputVal ==undefined || this.data.inputVal ==''){

        wx.showToast({

          title: '请输入播单名称',
          icon:'none'

        })

        return
      }

      var name = this.data.inputVal

      var myBd = wx.getStorageSync('myBoDan')

      if(myBd == ''){

        wx.setStorage({
          key:'myBoDan',
          data:JSON.stringify({data:[{id:id,name:name,imgSrc:'https://6a69-jiangli-u21is-1302255938.tcb.qcloud.la/icon/praiseGod.jpg'}]})
        })

      }else{

        var myBdObj = JSON.parse(myBd)

        myBdObj.data.push({id:id,name:name,imgSrc:'https://6a69-jiangli-u21is-1302255938.tcb.qcloud.la/icon/praiseGod.jpg'})

        wx.setStorage({
          key:'myBoDan',
          data:JSON.stringify(myBdObj)
        })


      }

      this.setData({
        display:true
      })

      wx.showToast({
        title: '创建成功',
      })

      //触发成功回调
      this.triggerEvent("add");

    },
    hidden:function(){

      var self =  this

      this.setData({
        display:!this.data.display
      })


    },
    show:function(){

      this.setData({
        display:!this.data.display
      })

    },
    onInput:function(e){

      var str = e.detail.value

      this.setData({
        inputVal:str
      })


    }


    
  }
})

